<template>
  <el-dialog :title="dTitle" :visible="visible" width="50%" :before-close="closeDialog">
    <el-form :model="formInline" :inline="true" ref="formInline" class="form-style">
      <el-form-item  prop="name">
        <el-input placeholder=" 团长名称" v-model="formInline.name"></el-input>
      </el-form-item>
      <el-form-item>
       <el-button style="margin-left:10px" @click="clean('formInline')">重置</el-button>
        <el-button @click="search">查询</el-button>
      </el-form-item>
    </el-form>
        <div class="table-style">
        <el-table :data="tableData" border >
          <el-table-column prop="SalesManName" label="团长名称"></el-table-column>
          <el-table-column prop="SalesManPhone" label="团长手机号"></el-table-column>
          <el-table-column label="操作" width="130">
            <template slot-scope="scope">
              <el-button @click="setSalesManName(scope.row.SalesManName,scope.row.UserId)" size="mini">选择</el-button>
            </template>
          </el-table-column>
        </el-table>
      <!-- <el-form-item style="margin-left:200px">
        <el-button @click="visible = false">取消</el-button>
        <el-button @click="upload('formInline')">确定</el-button>
      </el-form-item>-->
        <botpage
          class="botpage-style"
          :currentPage="currentPage"
          :pageSize="pageSize"
          :total="total"
          @handleCurrentChange="currentChange"
          @pageSizeChange="pageSizeChange"
        />
      </div>
  </el-dialog>
</template>

<script>
import { LoadSalesMan } from "@/request/api";
import Botpage from "@/components/botpage/Botpage";
export default {
  data() {
    return {
      currentPage: 1,
      pageSize: 10,
      total: 1,
      tableData: [],
      dialogImageUrl: "",
      dialogVisible: false,
      disabled: false,
      formInline: {},
      SalesManName:'',
      userId:"",
    };
  },
  props: {
    dTitle: {
      type: String,
      default: "",
    },
    visible: {
      type: Boolean,
      default: false,
    },
    // formData: {
    //   type: Object,
    //   default: {},
    // },
  },
  mounted() {
    this.$nextTick(function () {
      // this.formInline = this.formData;
    });
  },
  // watch: {
  //   formData(newVal, oldVal) {
  //     if (newVal) {
  //       this.formInline = { ...newVal };
  //     }
  //   },
  // },
  methods: {
    getTableDatas() {
      LoadSalesMan({
        PageIndex: this.currentPage,
        PageSize: this.pageSize,
        OS: "PC",
        CustomerId: 1,
        SreachValues:this.formInline.name
      }).then((res) => {
        this.currentPage = res.PageIndexs;
        this.pageSize = res.PageCount;
        this.tableData = res.Data;
        this.total = res.DataCounts;
      });
    },
    closeDialog(reload) {
      //子传父
      this.$emit("closeDialog", reload);
    },
    handleRemove(file) {
      console.log(file);
    },
    clean(formInline) {
      this.$refs[formInline].resetFields();
    },
    search() {
      this.getTableDatas()
    },
    currentChange(event) {
      console.log(event);
      this.currentPage = event;
      this.getTableDatas();
    },
    pageSizeChange(event) {
      this.pageSize = event;
      this.getTableDatas();
    },
    setSalesManName(name,id){
      console.log(name,id)
      this.SalesManName = name;
      this.userId = id
      this.$emit('getusername',this.SalesManName,this.userId);
      this.closeDialog()
    }
  },
  mounted(){
    this.getTableDatas()
  },
  components: {
    Botpage,
  },
};
</script>

<style lang="less" scoped>
</style>